//
// Created by jerry on 2024/6/5.
//

#include "sort.h"

char buf[0x100];


int main()
{
    int length;
    SqList list;
#if defined(WINNT)|| defined(WIN32)|| defined(WIN64)
    SetConsoleOutputCP(CP_UTF8);
#endif
    while (1)
    {
        printf("请输入数组长度:");
        if (scanf("%d", &length) == 1)
        {
            if (length < 0)
            {
                printf("%d:负数，无效输入\n", length);
                continue;
            }
            break;
        }
        EXCEPTION;
    }
    initList(&list, length);
    while(getchar()!='\n');
    while (1)
    {
        printf("1.直接插入排序\n");
        printf("2.简单选择排序\n");
        printf("3.堆排序\n");
        printf("0.退出\n\n");
        switch (
#if defined(WINNT)|| defined(WIN32)|| defined(WIN64)
                _getch()
#else
                getchar()
#endif
                )
        {
            case '1':
                InsertSort(list);
                break;
            case '2':
                SelectSort(list);
                break;
            case '3':
                HeapSort(&list);
                break;
            case 'q':
                printf("欢迎下次使用\n");
                return 0;
            default:
                EXCEPTION;
                continue;
        }
        showList(list);
        return 0;
    }
}